package com.skins;

import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;



public class BookmarkActivity extends Activity {
	/** Called when the activity is first created. */
	Button btn1, btn2;
	TextView text;
	
	Xml data;
	//DB dataBase;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.bookmark);
		
		
		btn1 =(Button)findViewById(R.id.btn1);
		btn2 =(Button)findViewById(R.id.btn2);
		text =(TextView)findViewById(R.id.textView1);
		
		btn1.setOnClickListener((OnClickListener) this);
		btn2.setOnClickListener((OnClickListener) this);

		//SQLiteOpenHelper dbHelper = new DBManager(this);
		//SQLiteDatabase db = dbHelper.getWritableDatabase();
		
		
	}
	public void onClick(View v){
		
		SQLiteOpenHelper dbHelper = new DBManager(this);
		SQLiteDatabase db = dbHelper.getWritableDatabase();
		if(v == btn1){
			String sql = "insert into skins values('a','b','c','d');";
			db.execSQL(sql);
			ContentValues cv = new ContentValues();
			cv.put("image", " ");
			cv.put("name", " ");
			cv.put("price", " ");
			cv.put("link", " ");
			db.insert("skins", null, cv);
			
			
		}else if(v == btn2){
			String sql= "select * from skins;";
			String [] args = {"100"};
			String [] columns ={"image", "name", "price" , "link"};
			Cursor result = db.query("skins", columns, null, args, null,null, null);
			
			String str ="";
			while(result.moveToNext()){
				String name = result.getString(0);
				String image = result.getString(1);
				String price = result.getString(2);
				String link = result.getString(3);
				str+=(name+" "+image+" "+price+" "+link+"\n");
				
			}
			text.setText(str);
		}
		db.close();
	}
}


